#pragma once

#include "Player.h"

inline bool PlayerComparisionGoal(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetScoredGoal() > i_b->GetScoredGoal();
}

inline bool PlayerComparisionTotalGoal(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetTotalScoredGoal() > i_b->GetTotalScoredGoal();
}

inline bool PlayerComparisionMatch(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetPlayedMatch() > i_b->GetPlayedMatch();
}
	
inline bool PlayerComparisionTotalMatch(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetTotalPlayedMatch() > i_b->GetTotalPlayedMatch();
}

inline bool PlayerComparisionTotalGoalRatio(const Player* const i_a, const Player* const i_b)
{
	if(((i_a->GetTotalPlayedMatch() < 100) && (i_b->GetTotalPlayedMatch() < 100)) ||
		((i_a->GetTotalPlayedMatch() >= 100) && (i_b->GetTotalPlayedMatch() >= 100)))
	{
		return i_a->GetTotalScoredGoalRatio() > i_b->GetTotalScoredGoalRatio();
	}

	return i_a->GetTotalPlayedMatch() > i_b->GetTotalPlayedMatch();
}

inline bool PlayerComparisionAge(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetAge() > i_b->GetAge();
}

inline bool PlayerComparisionAgeDown(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetAge() < i_b->GetAge();
}

inline bool PlayerComparisionNumSeason(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetNumSeason() > i_b->GetNumSeason();
}

inline bool PlayerComparisionNumInjury(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetNumOfInjury() > i_b->GetNumOfInjury();
}

inline bool PlayerComparisionSalary(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetSalary() > i_b->GetSalary();
}

inline bool PlayerComparisionResistance(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetSkills().m_resistance > i_b->GetSkills().m_resistance;
}

inline bool PlayerComparisionAverageSkill(const Player* const i_a, const Player* const i_b)
{
	return i_a->GetAverageSkill() > i_b->GetAverageSkill();
}

inline bool PlayerComparisionSellValue(const Player* const i_a, const Player* const i_b)
{
	return i_a->SellValue() > i_b->SellValue();
}

inline bool PlayerBuyChoose(const Player* const i_a, const Player* const i_b)
{
	const int w1 = 10;
	const int w3 = -20;
	const int w4 = -500;

	const int weightA = w1 * i_a->GetAverageSkill() + w3 * i_a->GetAge() + w4 * i_a->GetDaysUnavaiable();
	const int weightB = w1 * i_b->GetAverageSkill() + w3 * i_b->GetAge() + w4 * i_b->GetDaysUnavaiable();

	return weightA > weightB;
}

struct PlayerComparisionSkill
{
	explicit PlayerComparisionSkill(const int i_skill):m_skill(i_skill){}
	bool operator()(const Player* const i_a, const Player* const i_b) const
	{
		return (i_a->GetSkill(m_skill) > i_b->GetSkill(m_skill));
	}
	int m_skill;
};
